package com.ukao.pad.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.pad.R;
import com.ukao.pad.bean.ClothesOperateStatusBean;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by kefu001 on 2018/5/30.
 */

public class ClothesOperateStatusAdapter  extends CommonAdapter<ClothesOperateStatusBean> {

    public ClothesOperateStatusAdapter(Context context, List<ClothesOperateStatusBean> datas) {
        super(context, datas, R.layout.adapter_clothes_operation_status_item);
    }
    @Override
    public void convert(ViewHolder viewHolder, ClothesOperateStatusBean clothesOperateStatusBean) {

        CircleImageView circleImageView=viewHolder.getView(R.id.circle_image);
                viewHolder.getLayoutPosition();
        View view=viewHolder.getView(R.id.line_normal);
        TextView passStep=viewHolder.getView(R.id.tv_pass_step);
        TextView operatorName=viewHolder.getView(R.id.tv_operator_name);
        TextView  specificTime=viewHolder.getView(R.id.tv_specific_time); //具体时间
        if(getPosition(viewHolder)==0){
            circleImageView.setImageResource(R.drawable.yellow_circle);
            passStep.setTextColor(mContext.getResources().getColor(R.color.gold));
            specificTime.setTextColor(mContext.getResources().getColor(R.color.gold));
            operatorName.setTextColor(mContext.getResources().getColor(R.color.gold));
        }else {
            circleImageView.setImageResource(R.drawable.gray_circle);
            passStep.setTextColor(mContext.getResources().getColor(R.color.gray33));
            specificTime.setTextColor(mContext.getResources().getColor(R.color.gray33));
            operatorName.setTextColor(mContext.getResources().getColor(R.color.gray33));
        }
        if(getPosition(viewHolder)==getDatas().size()-1){
            view.setVisibility(View.GONE);
        }else {
            view.setVisibility(View.VISIBLE);
        }
        if(!TextUtils.isEmpty(clothesOperateStatusBean.getStatusText())){
            passStep.setText(clothesOperateStatusBean.getStatusText());
        }
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d1=new Date(clothesOperateStatusBean.getCreateTime());
        String strTime=format.format(d1);
        specificTime.setText(strTime);
        if(!TextUtils.isEmpty(clothesOperateStatusBean.getCreateName())){
            operatorName.setText(clothesOperateStatusBean.getCreateName());  //操作人员
        }

    }
}
